package com.ha7419x.controller;

import com.ha7419x.service.IDeptClientService;
import com.ha7419x.vo.Dept;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class ConsumerDeptController {
    @Resource
    private IDeptClientService deptClientService;

    @RequestMapping(value = "consumer/dept/get/{id}", method = RequestMethod.GET)
    public Object getDept(@PathVariable("id") Long id){
        return this.deptClientService.get(id);
    }

    @RequestMapping(value = "consumer/dept/list", method = RequestMethod.GET)
    public Object list(){
        return this.deptClientService.list();
    }

    @RequestMapping(value = "consumer/dept/add", method = RequestMethod.GET)
    public Object addDept(@RequestParam("deptName") String deptName){
        Dept dept = new Dept();
        dept.setDeptName(deptName);
        return this.deptClientService.add(dept);
    }
}
